package com.symria.client.common;

import java.util.Date;

import com.symria.framework.page.ATTPage;
import com.symria.framework.page.Page;
import com.symria.framework.page.PagerFactory;
import com.symria.framework.util.BaseAction;
import com.symria.server.bo.app.APPService;
import com.symria.server.bo.campaign.CampaignService;
import com.symria.server.po.AppInfo;

public class AppAction extends BaseAction {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private CampaignService campaignService;
	private APPService appService;
	private AppInfo ap;
	private Date beginDate;
	private Date endDate;
	private String state;
	private Integer appId;
	
	public Integer getAppId() {
		return appId;
	}
	public void setAppId(Integer appId) {
		this.appId = appId;
	}
	public String getState() {
		return state;
	}
	public void setState(String state) {
		this.state = state;
	}
	public APPService getAppService() {
		return appService;
	}
	public void setAppService(APPService appService) {
		this.appService = appService;
	}
	public CampaignService getCampaignService() {
		return campaignService;
	}
	public void setCampaignService(CampaignService campaignService) {
		this.campaignService = campaignService;
	}
	public AppInfo getAp() {
		return ap;
	}
	public void setAp(AppInfo ap) {
		this.ap = ap;
	}
	public Date getBeginDate() {
		return beginDate;
	}
	public void setBeginDate(Date beginDate) {
		this.beginDate = beginDate;
	}
	public Date getEndDate() {
		return endDate;
	}
	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}
	public String searchApp(){
		Page page = PagerFactory.createPage();
		campaignService.searchApp(ap, beginDate, endDate, page);
		setAttr("app", ap);
		setAttr(ATTPage.PAGE_LIST, page);
		return SUCCESS;
	}
	public String manageApp(){	
		AppInfo app=appService.findAppInfoById(ap.getAppId());
		setAttr("app", app);
		return SUCCESS;
	}
	public String updateAppStatus(){
		AppInfo app = appService.getObject(appId, AppInfo.class);
		appService.updateAppState(app, state);
		return SUCCESS;
	}
	
}
